//
// NoticeListView.js
//

import React, { Component } from 'react'
import {
  Text,
  View,
  TouchableHighlight,
  Image,
  FlatList,
} from 'react-native'

import {__screenWidth,__navigator} from '../Common/Utls/Utls'

export default class  NoticeListView  extends  Component {
  constructor(props) {
    super(props)

    this.state = {
      bRefresh:false
    }
  };

  _refresh() {
    this.setState({
      bRefresh:true
    })
  }

  _noticeCell(item) {
    //const {navigate} = this.state.navigation;
    return (
      <TouchableHighlight key={item.key} onPress={()=>{__navigator.push('NoticeDetailView')}}>
       <View style={{backgroundColor:'white'}}>
         <View style={{flexDirection:'row',height:50}}>
             <View key='left' style={{alignSelf:'center',marginLeft:10,maxWidth:(__screenWidth-54)}}>
               <Text key='title' numberOfLines={1} style={{color:'#444444',fontSize:14}}>{item.title}</Text>
               <Text key='sub-title' style={{color:'#888888',fontSize:11,marginTop:6}}>{item.subTitle}</Text>
             </View>
             <View style={{flexGrow:1}}/>
             <View key='right' style={{alignSelf:'center',marginRight:10,marginTop:-10}}>
               <Text style={{color:'#888888',fontSize:11}}>{item.time}</Text>
             </View>
         </View>
         <View style={{backgroundColor:'#e0e0e0',height:0.5,flexGrow:1}}/>
       </View>
      </TouchableHighlight>
    )
  };

  _myNoticeSection() {
    let data = [
      {
        key:0,
        title:'关于培育创建江苏特色小镇的实施方案......abcdefg',
        subTitle:'阅读：50',
        time:'12:24',
      },
      {
        key:1,
        title:'关于印发《江宁区鼓励支持企业自主引进人才...',
        subTitle:'阅读：90',
        time:'昨天',
      },
      {
        key:2,
        title:'关于开展2017年度江苏省企业知识产权',
        subTitle:'阅读：350',
        time:'12:01',
      },
      {
        key:3,
        title:'关于培育创建江苏特色小镇的实施方案3',
        subTitle:'阅读：50',
        time:'05-19',
      },
      {
        key:4,
        title:'关于培育创建江苏特色小镇的实施方案3aaaaaaaaaaaaaabc',
        subTitle:'阅读：50',
        time:'05-19',
      },
      {
        key:5,
        title:'3aaaaaaaaaaaaaabc,关于培育创建江苏特色小镇的实施方案',
        subTitle:'阅读：50',
        time:'05-19',
      },
    ];

    if (this.state.bRefresh) {
      data.push(
        {
          key:6,
          title:'QQQQQQ关于培育创建江苏特色小镇的实施方案',
          subTitle:'阅读：50',
          time:'05-19',
        },
        {
          key:7,
          title:'3aaaaaaaaaaaaaabc,关于培育创建江苏特色小镇的实施方案d',
          subTitle:'阅读：50',
          time:'05-19',
        },
        {
          key:8,
          title:'ZZZZZ,关于培育创建江苏特色小镇的实施方案',
          subTitle:'阅读：1250',
          time:'05-19',
        },
      )
    }

    return (
      <View style={{flexGrow:1,backgroundColor:'white'}}>
        <FlatList key='FlatList' data={data} renderItem={
          ({item}) => this._noticeCell(item)
        } style={{flexGrow:1}}/>
      </View>
    )
  };

  render() {
    return (
      <View style={{flexGrow:1}}>{this._myNoticeSection()}</View>
    )
  }
};
